jQuery(function($) {
	
});
var queryInfo = function(){
	var userId = $("#queryUserId").val();
	$("#submitUserId").val(userId);
	$.ajax({
		type:"POST",
		url:ctx + "/admin/addUser/queryUserInfo?userId="+userId,
		cache:false,
		success:function(data){
			$("#user-profile-1").html(data);
			if($("#user-profile-1 #noDataDiv").length <= 0){
				$("#formDiv").show();
			}else{
				$("#formDiv").hide();
			}
			
		}
	});
}
var check = function(){
	return true;
}
var submitAdd = function(){
	if(!check()){
        return;
	}
    var data = $("#addSubUserForm").serialize();
    $.ajax({
        type:"POST",
        url:"addSubUserSubmit",
        data:data,
		dataType:"json",
        cache:false,
        success:function(data){
            alert(data.msg);
            if(data.code != "0"){
            	cancelAdd();
            }
        }
    });
}
var cancelAdd = function(){
	$("#user-profile-1").html("");
	$("#formDiv").hide();
}
var loadMyPayData = function(userId,agentId){
	dataUrl = ctx + "/admin/finance/userfinanceList/myPayList";
	$('#queryDetailForm input[name="userId"]').val(userId);
	$('#queryDetailForm input[name="agentId"]').val(agentId);
	$('#queryDetailForm input[name="type"]').val(1);
	var data = $("#queryDetailForm").serialize();
	$.ajax({
		type:"POST",
		url:dataUrl,
		data:data,
		cache:false,
		success:function(data){
			$("#"+contextId).html(data);
		}
	});
}
var loadMyPlayerData = function(userId,agentId){
	dataUrl = ctx + "/admin/finance/userfinanceList/myPalayerList";
	$('#queryDetailForm input[name="userId"]').val(userId);
	$('#queryDetailForm input[name="agentId"]').val(agentId);
	$('#queryDetailForm input[name="type"]').val(2);
	var data = $("#queryDetailForm").serialize();
	$.ajax({
		type:"POST",
		url:dataUrl,
		data:data,
		cache:false,
		success:function(data){
			$("#"+contextId).html(data);
		}
	});
}
var loadMyAgentData = function(userId,agentId){
	dataUrl = ctx + "/admin/finance/userfinanceList/myAgentList";
	$('#queryDetailForm input[name="userId"]').val(userId);
	$('#queryDetailForm input[name="agentId"]').val(agentId);
	$('#queryDetailForm input[name="type"]').val(3);
	var data = $("#queryDetailForm").serialize();
	$.ajax({
		type:"POST",
		url:dataUrl,
		data:data,
		cache:false,
		success:function(data){
			$("#"+contextId).html(data);
		}
	});
}

var showOnePlayerDetail = function(userId){
	dataUrl = ctx + "/admin/finance/userfinanceList/myPayList";
	$('#queryDetailForm input[name="userId"]').val(userId);
	$('#queryDetailForm input[name="type"]').val(1);
	var data = $("#queryDetailForm").serialize();
	$.ajax({
		type:"POST",
		url:dataUrl,
		data:data,
		cache:false,
		success:function(data){
			$("#"+contextId).html(data);
		}
	});
}
var showOneAgentDetail = function(agentId,userId){
	dataUrl = ctx + "/admin/finance/userfinanceList/myAgentList";
	$('#queryDetailForm input[name="agentId"]').val(agentId);
	$('#queryDetailForm input[name="userId"]').val(userId);
	$('#queryDetailForm input[name="type"]').val(3);
	var data = $("#queryDetailForm").serialize();
	$.ajax({
		type:"POST",
		url:dataUrl,
		data:data,
		cache:false,
		success:function(data){
			$("#"+contextId).html(data);
		}
	});
}
var excel = function(){
	if(!queryDetailForm){
		return;
	}
	var form = $(queryDetailForm);
	form.attr("action", ctx+"/admin/excelExport/userInfoExport");
	form.submit();
}